package sctu.edu.java.year2016.team04.Liliang.day20160523.chapter6_2;

/**
 * Created by asus on 2016/5/23.
 * 只利用for循环和if条件句实现去除空格。
 */
public class Six_2 {
    public static void main(String[] args) {
        String date = "java six 2";
        System.out.println(date + "去除空格后的值为：");
        char date2[] = new char[10];

        for(int i=0,j=0;i<date.length();i++){
            if(date.charAt(i)!=' ') {
                date2[j] = date.charAt(i);
                j++;
            }
        }
        date=new String(date2);
        System.out.println(date);
    }
}
